class GameStats():
    def __init__(self, ai_settings):
        self.ai_settings = ai_settings
        self.reset_stats()
        self.game_active = False
        try:
            with open(r'txt/highscore.txt') as history_high_score_file:
                history_high_score = history_high_score_file.read().rstrip()
        except FileNotFoundError:
            print("no files")
            self.high_score = 0
        else:
            try:
                self.high_score = int(history_high_score)
            except ValueError:
                print("no scores")
                self.high_score = 0

    def reset_stats(self):
        self.ships_left = self.ai_settings.ship_limit
        self.score = 0
        self.level = 1
